package com.example.demo.service.ThreadPool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.concurrent.Executor;

@Service
@Slf4j
public class ThreadPoolService {

    @Autowired
    @Qualifier("defaultExecutor")
    private Executor executor;

    public void executor(ThreadPoolTask threadPoolTask){
        if(threadPoolTask == null){
            log.error("传入的线程池任务参数为空");
        }
        executor.execute(threadPoolTask::todoTask);
    }
}
